﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VKDSTAMM
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                default:
                    #region=========
                    dwReturn["KDMANDANT"] = app.Mandant;
                    dwReturn["KDKUNDNR"] = "        ";
                    dwReturn["KDKUNDNA"] = "        ";
                    dwReturn["KDLAND"] = "   ";
                    dwReturn["KDPLZ"] = "            ";
                    dwReturn["KDORT"] = "                                        ";
                    dwReturn["KDBZ"] = "  ";
                    dwReturn["KDBZBEZ"] = "             ";
                    dwReturn["KDSTAKZ"] = "A";
                    dwReturn["KDSTADAT"] = 0;
                    dwReturn["KDABCKL"] = " ";
                    dwReturn["KDANREDE"] = " ";
                    dwReturn["KDNAME1"] = "                                        ";
                    dwReturn["KDKNAME"] = "               ";
                    dwReturn["KDNAME2"] = "                                        ";
                    dwReturn["KDSTRASSE1"] = "                                        ";
                    dwReturn["KDSTRASSE2"] = "                                        ";
                    dwReturn["KDPLZPOSTF"] = "            ";
                    dwReturn["KDPOSTFACH"] = "               ";
                    dwReturn["KDTEL"] = "                    ";
                    dwReturn["KDTELEX"] = "                    ";
                    dwReturn["KDFAX"] = "                    ";
                    dwReturn["KDBTX"] = "                    ";
                    dwReturn["KDDATEX"] = "                    ";
                    dwReturn["KDHOMEPAGE"] = "                                        ";
                    dwReturn["KDMAILADR"] = "                                                                                                    ";
                    dwReturn["KDTTEX"] = "                    ";
                    dwReturn["KDCOUNTY"] = "    ";
                    dwReturn["KDCITY"] = "    ";
                    dwReturn["KDZENTR"] = "        ";
                    dwReturn["KDZENTRR"] = " ";
                    dwReturn["KDSPRKZ"] = "V";
                    dwReturn["KDBBN"] = "                    ";
                    dwReturn["KDSONDSTA"] = " ";
                    dwReturn["KDKDNRALT"] = "          ";
                    dwReturn["KDLO"] = "  ";
                    dwReturn["KDLB"] = "  ";
                    dwReturn["KDLP"] = "        ";
                    dwReturn["KDLIEFNR"] = "                ";
                    dwReturn["KDINVDAT"] = "0";
                    dwReturn["KDDEBNR"] = "00000000";
                    dwReturn["KDKREDNR"] = "00000000";
                    dwReturn["KDUEBKZ"] = "N";
                    dwReturn["KDAUSK"] = "0";
                    dwReturn["KDAUSKKZ"] = "  ";
                    dwReturn["KDMAHNST"] = " ";
                    dwReturn["KDMAHNH"] = "00000";
                    dwReturn["KDGRPCUNO"] = "1       ";
                    dwReturn["KDCLEARCUNO"] = "        ";
                    dwReturn["KDBIC1"] = "           ";
                    dwReturn["KDIBAN1"] = "                                  ";
                    dwReturn["KDBIC2"] = "           ";
                    dwReturn["KDIBAN2"] = "                                  ";
                    dwReturn["KDKREDLIM1"] = "0";
                    dwReturn["KDKREDVON1"] = "0";
                    dwReturn["KDKREDBIS1"] = "0";
                    dwReturn["KDKREDNLDAT1"] = "0";
                    dwReturn["KDVERS1"] = "  ";
                    dwReturn["KDVERS21"] = "  ";
                    dwReturn["KDKREDSB1"] = "        ";
                    dwReturn["KDVERSTAGE1"] = "0";
                    dwReturn["KDVERSNR1"] = "          ";
                    dwReturn["KDKREDLIM2"] = "0";
                    dwReturn["KDKREDVON2"] = "0";
                    dwReturn["KDKREDBIS2"] = "0";
                    dwReturn["KDKREDNLDAT2"] = "0";
                    dwReturn["KDVERS2"] = "  ";
                    dwReturn["KDVERS22"] = "  ";
                    dwReturn["KDKREDSB2"] = "        ";
                    dwReturn["KDVERSTAGE2"] = "0";
                    dwReturn["KDVERSNR2"] = "          ";
                    dwReturn["KDKREDLIM3"] = "0";
                    dwReturn["KDKREDVON3"] = "0";
                    dwReturn["KDKREDBIS3"] = "0";
                    dwReturn["KDKREDNLDAT3"] = "0";
                    dwReturn["KDVERS3"] = "  ";
                    dwReturn["KDVERS23"] = "  ";
                    dwReturn["KDKREDSB3"] = "        ";
                    dwReturn["KDVERSTAGE3"] = "0";
                    dwReturn["KDVERSNR3"] = "          ";
                    dwReturn["KDKREDLIM4"] = "0";
                    dwReturn["KDKREDVON4"] = "0";
                    dwReturn["KDKREDBIS4"] = "0";
                    dwReturn["KDKREDNLDAT4"] = "0";
                    dwReturn["KDVERS4"] = "  ";
                    dwReturn["KDVERS24"] = "  ";
                    dwReturn["KDKREDSB4"] = "        ";
                    dwReturn["KDVERSTAGE4"] = "0";
                    dwReturn["KDVERSNR4"] = "          ";
                    dwReturn["KDKREDLIM5"] = "0";
                    dwReturn["KDKREDVON5"] = "0";
                    dwReturn["KDKREDBIS5"] = "0";
                    dwReturn["KDKREDNLDAT5"] = "0";
                    dwReturn["KDVERS5"] = "  ";
                    dwReturn["KDVERS25"] = "  ";
                    dwReturn["KDKREDSB5"] = "        ";
                    dwReturn["KDVERSTAGE5"] = "0";
                    dwReturn["KDVERSNR5"] = "          ";
                    dwReturn["KDKREDEHA"] = "0";
                    dwReturn["KDKREDEHAR"] = "  ";
                    dwReturn["KDKREDNOLI"] = "  ";
                    dwReturn["KDKREDNOLIV"] = "0";
                    dwReturn["KDKREDNOLIB"] = "0";
                    dwReturn["KDAUFBESTTO"] = "0";
                    dwReturn["KDVERSUMLTO"] = "0";
                    dwReturn["KDOPSALDOTO"] = "0";
                    dwReturn["KDZUSKRED"] = "0";
                    dwReturn["KDZKREVON"] = "0";
                    dwReturn["KDZKREBIS"] = "0";
                    dwReturn["KDZKREDSB"] = "        ";
                    dwReturn["KDOPSALDO"] = "0";
                    dwReturn["KDWEOBLIGO"] = "0";
                    dwReturn["KDVERSUML"] = "0";
                    dwReturn["KDSPERRKZ"] = "N";
                    dwReturn["KDSPERRGRD"] = "   ";
                    dwReturn["KDLAUFDAT"] = "0";
                    dwReturn["KDBUCHHDAT"] = "0";
                    dwReturn["KDBRANCHE"] = "   ";
                    dwReturn["KDFAKTART"] = "   ";
                    dwReturn["KDKORT"] = "          ";
                    dwReturn["KDLIMITKZ"] = "N";
                    dwReturn["KDSPLIEFKZ"] = " ";
                    dwReturn["KDAUFBEST"] = "0";
                    dwReturn["KDAUFBESTU"] = "0";
                    dwReturn["KDPREISPRF"] = "J";
                    dwReturn["KDMATPRF"] = "J";
                    dwReturn["KDBRTPRF"] = "J";
                    dwReturn["KDGQMPRF"] = "J";
                    dwReturn["KDSTKGPRF"] = "J";
                    dwReturn["KDSCHLIPRF"] = "J";
                    dwReturn["KDSCHLIABW"] = "J";
                    dwReturn["KDDRPAR"] = "     ";
                    dwReturn["KDMWSTID"] = "                    ";
                    dwReturn["KDMWSTID2"] = "                    ";
                    dwReturn["KDLBMUSTR"] = "   ";
                    dwReturn["KDFBMUSTR"] = "   ";
                    dwReturn["KDSTLAND"] = "  ";
                    dwReturn["KDSTREGBZ"] = "  ";
                    dwReturn["KDSTKREIS"] = "  ";
                    dwReturn["KDSTORT"] = "   ";
                    dwReturn["KDLSART"] = "   ";
                    dwReturn["KDREGMWST"] = "T  ";
                    dwReturn["KDMUSTERKZ"] = " ";
                    dwReturn["KDUMSVVJH"] = "00000000000";
                    dwReturn["KDUMSVJH"] = "00000000000";
                    dwReturn["KDUMSLJH"] = "00000000000";
                    dwReturn["KDUMSVVJHV"] = "00000000000";
                    dwReturn["KDUMSVJHV"] = "00000000000";
                    dwReturn["KDUMSLJHV"] = "00000000000";
                    dwReturn["KDUMSVVJHS"] = "00000000000";
                    dwReturn["KDUMSVJHS"] = "00000000000";
                    dwReturn["KDUMSLJHS"] = "00000000000";
                    dwReturn["KDQTYUT"] = "   ";
                    dwReturn["KDQTYVVJH"] = "00000000000";
                    dwReturn["KDQTYVJH"] = "00000000000";
                    dwReturn["KDQTYLJH"] = "00000000000";
                    dwReturn["KDQTYVVJHV"] = "00000000000";
                    dwReturn["KDQTYVJHV"] = "00000000000";
                    dwReturn["KDQTYLJHV"] = "00000000000";
                    dwReturn["KDQTYVVJHS"] = "00000000000";
                    dwReturn["KDQTYVJHS"] = "00000000000";
                    dwReturn["KDQTYLJHS"] = "00000000000";
                    dwReturn["KDPRFZEUG"] = " ";
                    dwReturn["KDKONZMIT"] = "N";
                    dwReturn["KDRAITING"] = "   ";
                    dwReturn["KDRECHWERT1"] = "0000000000";
                    dwReturn["KDRECHWERT2"] = "0000000000";
                    dwReturn["KDRECHWERT3"] = "0000000000";
                    dwReturn["KDRECHWERT4"] = "0000000000";
                    dwReturn["KDRECHWERT5"] = "0000000000";
                    dwReturn["KDKREDKDNR"] = "        ";
                    dwReturn["KDKOND"] = "K";
                    dwReturn["KDKDARTBEZ"] = "K";
                    dwReturn["KDKFIBUDAT"] = "0";
                    dwReturn["KDKFIBUZEIT"] = "0";
                    dwReturn["KDILN"] = "             ";
                    dwReturn["KDDEBNRLAE"] = "0";
                    dwReturn["KDFACLIMIT"] = "0";
                    dwReturn["KDSHIPINVD"] = "000";
                    dwReturn["KDAUFBUTO"] = "0";
                    dwReturn["KDMAXBST"] = "00000";
                    dwReturn["KDGRUPPE"] = " ";
                    dwReturn["KDEORI"] = "                 ";
                    dwReturn["KDEORINL"] = "0000";
                    dwReturn["KDNTSCV"] = " ";
                    dwReturn["KDNTSCE"] = " ";
                    dwReturn["KDKEYAC"] = "        ";
                    dwReturn["KDKTOGRP"] = "  ";
                    dwReturn["KDZAHLUNG"] = " ";
                    dwReturn["KDPRAEMIE"] = " ";
                    dwReturn["KDFILLER"] = "                                                                                           ";
                    dwReturn["KDAENZL"] = "0";
                    dwReturn["KDAENB"] = "        ";
                    dwReturn["KDAEND"] = "0";
                    dwReturn["KDNEUB"] = "        ";
                    dwReturn["KDNEUD"] = "0";

                    #endregion
                    break;
            }
        }

        public void InsertKDSTAMM(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            dwData["KDNEUB"] = app.User;
            dwData["KDNEUD"] = date;
            or1 = OracleDB.CreateCommand();

            switch (ITXDBVERSION)
            {
                case "YGR":
                case "SXN":
                case "TST":
                default:
                    or1.CommandText = "INSERT INTO KDSTAMM(KDMANDANT, KDKUNDNR, KDKUNDNA, KDLAND, KDPLZ, KDORT, KDBZ, KDBZBEZ, KDSTAKZ, KDSTADAT, KDABCKL, KDANREDE, KDNAME1, KDKNAME, KDNAME2, KDSTRASSE1, KDSTRASSE2, KDPLZPOSTF, KDPOSTFACH, KDTEL, KDTELEX, KDFAX, KDBTX, KDDATEX, KDHOMEPAGE, KDMAILADR, KDTTEX, KDCOUNTY, KDCITY, KDZENTR, KDZENTRR, KDSPRKZ, KDBBN, KDSONDSTA, KDKDNRALT, KDLO, KDLB, KDLP, KDLIEFNR, KDINVDAT, KDDEBNR, KDKREDNR, KDUEBKZ, KDAUSK, KDAUSKKZ, KDMAHNST, KDMAHNH, KDGRPCUNO, KDCLEARCUNO, KDBIC1, KDIBAN1, KDBIC2, KDIBAN2, KDKREDLIM1, KDKREDVON1, KDKREDBIS1, KDKREDNLDAT1, KDVERS1, KDVERS21, KDKREDSB1, KDVERSTAGE1, KDVERSNR1, KDKREDLIM2, KDKREDVON2, KDKREDBIS2, KDKREDNLDAT2, KDVERS2, KDVERS22, KDKREDSB2, KDVERSTAGE2, KDVERSNR2, KDKREDLIM3, KDKREDVON3, KDKREDBIS3, KDKREDNLDAT3, KDVERS3, KDVERS23, KDKREDSB3, KDVERSTAGE3, KDVERSNR3, KDKREDLIM4, KDKREDVON4, KDKREDBIS4, KDKREDNLDAT4, KDVERS4, KDVERS24, KDKREDSB4, KDVERSTAGE4, KDVERSNR4, KDKREDLIM5, KDKREDVON5, KDKREDBIS5, KDKREDNLDAT5, KDVERS5, KDVERS25, KDKREDSB5, KDVERSTAGE5, KDVERSNR5, KDKREDEHA, KDKREDEHAR, KDKREDNOLI, KDKREDNOLIV, KDKREDNOLIB, KDAUFBESTTO, KDVERSUMLTO, KDOPSALDOTO, KDZUSKRED, KDZKREVON, KDZKREBIS, KDZKREDSB, KDOPSALDO, KDWEOBLIGO, KDVERSUML, KDSPERRKZ, KDSPERRGRD, KDLAUFDAT, KDBUCHHDAT, KDBRANCHE, KDFAKTART, KDKORT, KDLIMITKZ, KDSPLIEFKZ, KDAUFBEST, KDAUFBESTU, KDPREISPRF, KDMATPRF, KDBRTPRF, KDGQMPRF, KDSTKGPRF, KDSCHLIPRF, KDSCHLIABW, KDDRPAR, KDMWSTID, KDMWSTID2, KDLBMUSTR, KDFBMUSTR, KDSTLAND, KDSTREGBZ, KDSTKREIS, KDSTORT, KDLSART, KDREGMWST, KDMUSTERKZ, KDUMSVVJH, KDUMSVJH, KDUMSLJH, KDUMSVVJHV, KDUMSVJHV, KDUMSLJHV, KDUMSVVJHS, KDUMSVJHS, KDUMSLJHS, KDQTYUT, KDQTYVVJH, KDQTYVJH, KDQTYLJH, KDQTYVVJHV, KDQTYVJHV, KDQTYLJHV, KDQTYVVJHS, KDQTYVJHS, KDQTYLJHS, KDPRFZEUG, KDKONZMIT, KDRAITING, KDRECHWERT1, KDRECHWERT2, KDRECHWERT3, KDRECHWERT4, KDRECHWERT5, KDKREDKDNR, KDKOND, KDKDARTBEZ, KDKFIBUDAT, KDKFIBUZEIT, KDILN, KDDEBNRLAE, KDFACLIMIT, KDSHIPINVD, KDAUFBUTO, KDMAXBST, KDGRUPPE, KDEORI, KDEORINL, KDNTSCV, KDNTSCE, KDKEYAC, KDKTOGRP, KDZAHLUNG, KDPRAEMIE, KDFILLER, KDAENZL, KDAENB, KDAEND, KDNEUB, KDNEUD)"
                    + "VALUES(:KDMANDANT:,:KDKUNDNR:,:KDKUNDNA:,:KDLAND:,:KDPLZ:,:KDORT:,:KDBZ:,:KDBZBEZ:,:KDSTAKZ:,:KDSTADAT:,:KDABCKL:,:KDANREDE:,:KDNAME1:,:KDKNAME:,:KDNAME2:,:KDSTRASSE1:,:KDSTRASSE2:,:KDPLZPOSTF:,:KDPOSTFACH:,:KDTEL:,:KDTELEX:,:KDFAX:,:KDBTX:,:KDDATEX:,:KDHOMEPAGE:,:KDMAILADR:,:KDTTEX:,:KDCOUNTY:,:KDCITY:,:KDZENTR:,:KDZENTRR:,:KDSPRKZ:,:KDBBN:,:KDSONDSTA:,:KDKDNRALT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,:KDGQMPRF:,:KDSTKGPRF:,:KDSCHLIPRF:,:KDSCHLIABW:,:KDDRPAR:,:KDMWSTID:,:KDMWSTID2:,:KDLBMUSTR:,:KDFBMUSTR:,:KDSTLAND:,:KDSTREGBZ:,:KDSTKREIS:,:KDSTORT:,:KDLSART:,:KDREGMWST:,:KDMUSTERKZ:,:KDUMSVVJH:,:KDUMSVJH:,:KDUMSLJH:,:KDUMSVVJHV:,:KDUMSVJHV:,:KDUMSLJHV:,:KDUMSVVJHS:,:KDUMSVJHS:,:KDUMSLJHS:,:KDQTYUT:,:KDQTYVVJH:,:KDQTYVJH:,:KDQTYLJH:,:KDQTYVVJHV:,:KDQTYVJHV:,:KDQTYLJHV:,:KDQTYVVJHS:,:KDQTYVJHS:,:KDQTYLJHS:,:KDPRFZEUG:,:KDKONZMIT:,:KDRAITING:,:KDRECHWERT1:,:KDRECHWERT2:,:KDRECHWERT3:,:KDRECHWERT4:,:KDRECHWERT5:,:KDKREDKDNR:,:KDKOND:,:KDKDARTBEZ:,:KDKFIBUDAT:,:KDKFIBUZEIT:,:KDILN:,:KDDEBNRLAE:,:KDFACLIMIT:,:KDSHIPINVD:,:KDAUFBUTO:,:KDMAXBST:,:KDGRUPPE:,:KDEORI:,:KDEORINL:,:KDNTSCV:,:KDNTSCE:,:KDKEYAC:,:KDKTOGRP:,:KDZAHLUNG:,:KDPRAEMIE:,:KDFILLER:,:KDAENZL:,:KDAENB:,:KDAEND:,:KDNEUB:,:KDNEUD:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public override string BATCHINSERT(DataRow dwData)
        {
            dwData["KDNEUB"] = app.User;
            dwData["KDNEUD"] = date;
           
            string value = "";
            switch (app.company)
            {
                default:
                case "SXN":
                case "YGR":
                case "TST":
                    value = "INTO KDSTAMM"
                    + " VALUES( :KDMANDANT:,:KDKUNDNR:,:KDKUNDNA:,:KDLAND:,:KDPLZ:,:KDORT:,:KDB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AEND:,:KDNEUB:,:KDNEUD:)"
                    ;
                    value = INTEXDBC.InjectData(value, dwData);
                    break; 
            }
            return value;
        }

        public DataSet QueryKDSTAMM(DataRow dwData, int option = 1)
        {
            DataSet Result = null;
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT  KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING,M.* FROM KDSTAMM M WHERE  ROWNUM<2 ";
                    SResult = Connect2Proxy(or1);
                    break;
                case 1: SResult = QKD01(dwData); break;
                case 2:
                    or1.CommandText = "SELECT KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING, KDVERSUML,KDAUFBEST,KDVERSUMLTO,KDMANDANT,KDKUNDNR,KDKUNDNA,KDNAME1, KDSTRASSE1,KDKNAME,KDTEL,KDTELEX,KDFAX"
                    + " FROM KDSTAMM WHERE KDMANDANT=:KDMANDANT: ORDER BY KDKUNDNA";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                case 3:
                    or1.CommandText = "SELECT DISTINCT VVLIEFSCH,P.* FROM KDSTAMM P JOIN VVLIEF ON KDKUNDNR=VVKUNDNRE   "
                               + " WHERE VVMANDANT=:VVMANDANT AND  VVLIEFSCH=:VVLIEFSCH";
                    or1.Parameters.Add("VVMANDANT", OracleType.NVarChar).Value = dwData["VVMANDANT"].ToString();
                    or1.Parameters.Add("VVLIEFSCH", OracleType.NVarChar).Value = dwData["VVLIEFSCH"].ToString();
                    SResult = Connect2Proxy(or1);
                    break;
                case 4:
                    or1.CommandText = "SELECT KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING,M.* FROM KDSTAMM M WHERE   KDMANDANT=:KDMANDANT: AND KDKUNDNA=:KDKUNDNA:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                case 5:SResult = QKD05(dwData); break;

                case 99:
                    or1.CommandText = "SELECT KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING, M.* FROM KDSTAMM M";
                    SResult = Connect2Proxy(or1);
                    break;
                case -1:
                    or1.CommandText = "SELECT MAX(KDKUNDNR) AS KDKUNDNR FROM KDSTAMM WHERE KDMANDANT=:KDMANDANT:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    SResult = Connect2Proxy(or1);
                    break;
                case -2:
                    or1.CommandText = "SELECT DISTINCT KDKUNDNR,KDKUNDNA,KDNAME1, KDSTRASSE1,KDKNAME FROM KDSTAMM"
                        + " ORDER BY KDKUNDNA";
                    SResult = Connect2Proxy(or1);
                    break;
                default:
                    break;
            }
           
            SResult.Tables[0].TableName = "KDSTAMM";
            return SResult;
        }
        public DataSet QKD01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING,M.* FROM KDSTAMM M WHERE   KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1); 
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QKD05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT KDVERSUML - (KDAUFBEST + KDVERSUMLTO) AS SWING,  M.* "
            + " FROM KDSTAMM M WHERE KDMANDANT=:KDMANDANT: "
            + dwData["KDKUNDNA"].ToString()
            + dwData["KDNAME1"].ToString()
            + dwData["KDKUNDNR"].ToString()
            + " ORDER BY KDKUNDNR ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QKD999(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();

            or1.CommandText = "SELECT * FROM KDSTAMM WHERE KDMANDANT=:KDMANDANT: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }

        public void DeleteKDSTAMM(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM KDSTAMM WHERE   KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void DKD00(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand(); 
            or1.CommandText = "DELETE FROM KDSTAMM WHERE   KDMANDANT=:KDMANDANT: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            Connect2Proxy(or1);
        }


        public void UpdateKDSTAMM(DataRow dwData, int option = 1)
        {
            if (dwData != null)
            {
                dwData["KDAENB"] = app.User;
                dwData["KDAEND"] = date;
            }
            or1 = OracleDB.CreateCommand();
            if (option == 0)
            {
                switch (app.company)
                {
                    case "YGR":
                    case "SXN":
                    case "TST":
                    case "UBT":
                    default:
                        option = 2;
                        break;
                    case "JLT":
                        option = 5;
                        break; 
                }
            }
            switch (option)
            {
                case 1:
                    #region====Command====

                    or1.CommandText = "UPDATE KDSTAMM SET "
                        + "KDMANDANT=:KDMANDANT:,"
                        + "KDKUNDNR=:KDKUNDNR:,"
                        + "KDKUNDNA=:KDKUNDNA:,"
                        + "KDLAND=:KDLAND:,"
                        + "KDPLZ=:KDPLZ:,"
                        + "KDORT=:KDORT:,"
                        + "KDBZ=:KDBZ:,"
                        + "KDBZBEZ=:KDBZBEZ:,"
                        + "KDSTAKZ=:KDSTAKZ:,"
                        + "KDSTADAT=:KDSTADAT:,"
                        + "KDABCKL=:KDABCKL:,"
                        + "KDANREDE=:KDANREDE:,"
                        + "KDNAME1=:KDNAME1:,"
                        + "KDKNAME=:KDKNAME:,"
                        + "KDNAME2=:KDNAME2:,"
                        + "KDSTRASSE1=:KDSTRASSE1:,"
                        + "KDSTRASSE2=:KDSTRASSE2:,"
                        + "KDPLZPOSTF=:KDPLZPOSTF:,"
                        + "KDPOSTFACH=:KDPOSTFACH:,"
                        + "KDTEL=:KDTEL:,"
                        + "KDTELEX=:KDTELEX:,"
                        + "KDFAX=:KDFAX:,"
                        + "KDBTX=:KDBTX:,"
                        + "KDDATEX=:KDDATEX:,"
                        + "KDMBOX=:KDMBOX:,"
                        + "KDMAILADR=:KDMAILADR:,"
                        + "KDTTEX=:KDTTEX:,"
                        + "KDCOUNTY=:KDCOUNTY:,"
                        + "KDCITY=:KDCITY:,"
                        + "KDZENTR=:KDZENTR:,"
                        + "KDZENTRR=:KDZENTRR:,"
                        + "KDSPRKZ=:KDSPRKZ:,"
                        + "KDBBN=:KDBBN:,"
                        + "KDSONDSTA=:KDSONDSTA:,"
                        + "KDKDNRALT=:KDKDNRALT:,"
                        + "KDLO=:KDLO:,"
                        + "KDLB=:KDLB:,"
                        + "KDLP=:KDLP:,"
                        + "KDLIEFNR=:KDLIEFNR:,"
                        + "KDINVDAT=:KDINVDAT:,"
                        + "KDDEBNR=:KDDEBNR:,"
                        + "KDKREDNR=:KDKREDNR:,"
                        + "KDUEBKZ=:KDUEBKZ:,"
                        + "KDAUSK=:KDAUSK:,"
                        + "KDAUSKKZ=:KDAUSKKZ:,"
                        + "KDMAHNST=:KDMAHNST:,"
                        + "KDMAHNH=:KDMAHNH:,"
                        + "KDGRPCUNO=:KDGRPCUNO:,"
                        + "KDCLEARCUNO=:KDCLEARCUNO:,"
                        + "KDBIC1=:KDBIC1:,"
                        + "KDIBAN1=:KDIBAN1:,"
                        + "KDBIC2=:KDBIC2:,"
                        + "KDIBAN2=:KDIBAN2:,"
                        + "KDKREDLIM1=:KDKREDLIM1:,"
                        + "KDKREDVON1=:KDKREDVON1:,"
                        + "KDKREDBIS1=:KDKREDBIS1:,"
                        + "KDKREDNLDAT1=:KDKREDNLDAT1:,"
                        + "KDVERS1=:KDVERS1:,"
                        + "KDVERS21=:KDVERS21:,"
                        + "KDKREDSB1=:KDKREDSB1:,"
                        + "KDVERSTAGE1=:KDVERSTAGE1:,"
                        + "KDVERSNR1=:KDVERSNR1:,"
                        + "KDKREDLIM2=:KDKREDLIM2:,"
                        + "KDKREDVON2=:KDKREDVON2:,"
                        + "KDKREDBIS2=:KDKREDBIS2:,"
                        + "KDKREDNLDAT2=:KDKREDNLDAT2:,"
                        + "KDVERS2=:KDVERS2:,"
                        + "KDVERS22=:KDVERS22:,"
                        + "KDKREDSB2=:KDKREDSB2:,"
                        + "KDVERSTAGE2=:KDVERSTAGE2:,"
                        + "KDVERSNR2=:KDVERSNR2:,"
                        + "KDKREDLIM3=:KDKREDLIM3:,"
                        + "KDKREDVON3=:KDKREDVON3:,"
                        + "KDKREDBIS3=:KDKREDBIS3:,"
                        + "KDKREDNLDAT3=:KDKREDNLDAT3:,"
                        + "KDVERS3=:KDVERS3:,"
                        + "KDVERS23=:KDVERS23:,"
                        + "KDKREDSB3=:KDKREDSB3:,"
                        + "KDVERSTAGE3=:KDVERSTAGE3:,"
                        + "KDVERSNR3=:KDVERSNR3:,"
                        + "KDKREDLIM4=:KDKREDLIM4:,"
                        + "KDKREDVON4=:KDKREDVON4:,"
                        + "KDKREDBIS4=:KDKREDBIS4:,"
                        + "KDKREDNLDAT4=:KDKREDNLDAT4:,"
                        + "KDVERS4=:KDVERS4:,"
                        + "KDVERS24=:KDVERS24:,"
                        + "KDKREDSB4=:KDKREDSB4:,"
                        + "KDVERSTAGE4=:KDVERSTAGE4:,"
                        + "KDVERSNR4=:KDVERSNR4:,"
                        + "KDKREDLIM5=:KDKREDLIM5:,"
                        + "KDKREDVON5=:KDKREDVON5:,"
                        + "KDKREDBIS5=:KDKREDBIS5:,"
                        + "KDKREDNLDAT5=:KDKREDNLDAT5:,"
                        + "KDVERS5=:KDVERS5:,"
                        + "KDVERS25=:KDVERS25:,"
                        + "KDKREDSB5=:KDKREDSB5:,"
                        + "KDVERSTAGE5=:KDVERSTAGE5:,"
                        + "KDVERSNR5=:KDVERSNR5:,"
                        + "KDKREDEHA=:KDKREDEHA:,"
                        + "KDKREDEHAR=:KDKREDEHAR:,"
                        + "KDKREDNOLI=:KDKREDNOLI:,"
                        + "KDKREDNOLIV=:KDKREDNOLIV:,"
                        + "KDKREDNOLIB=:KDKREDNOLIB:,"
                        + "KDAUFBESTTO=:KDAUFBESTTO:,"
                        + "KDVERSUMLTO=:KDVERSUMLTO:,"
                        + "KDOPSALDOTO=:KDOPSALDOTO:,"
                        + "KDZUSKRED=:KDZUSKRED:,"
                        + "KDZKREVON=:KDZKREVON:,"
                        + "KDZKREBIS=:KDZKREBIS:,"
                        + "KDZKREDSB=:KDZKREDSB:,"
                        + "KDOPSALDO=:KDOPSALDO:,"
                        + "KDWEOBLIGO=:KDWEOBLIGO:,"
                        + "KDVERSUML=:KDVERSUML:,"
                        + "KDSPERRKZ=:KDSPERRKZ:,"
                        + "KDSPERRGRD=:KDSPERRGRD:,"
                        + "KDLAUFDAT=:KDLAUFDAT:,"
                        + "KDBUCHHDAT=:KDBUCHHDAT:,"
                        + "KDBRANCHE=:KDBRANCHE:,"
                        + "KDFAKTART=:KDFAKTART:,"
                        + "KDKORT=:KDKORT:,"
                        + "KDLIMITKZ=:KDLIMITKZ:,"
                        + "KDSPLIEFKZ=:KDSPLIEFKZ:,"
                        + "KDAUFBEST=:KDAUFBEST:,"
                        + "KDAUFBESTU=:KDAUFBESTU:,"
                        + "KDPREISPRF=:KDPREISPRF:,"
                        + "KDMATPRF=:KDMATPRF:,"
                        + "KDBRTPRF=:KDBRTPRF:,"
                        + "KDGQMPRF=:KDGQMPRF:,"
                        + "KDSTKGPRF=:KDSTKGPRF:,"
                        + "KDSCHLIPRF=:KDSCHLIPRF:,"
                        + "KDSCHLIABW=:KDSCHLIABW:,"
                        + "KDDRPAR=:KDDRPAR:,"
                        + "KDMWSTID=:KDMWSTID:,"
                        + "KDMWSTID2=:KDMWSTID2:,"
                        + "KDLBMUSTR=:KDLBMUSTR:,"
                        + "KDFBMUSTR=:KDFBMUSTR:,"
                        + "KDSTLAND=:KDSTLAND:,"
                        + "KDSTREGBZ=:KDSTREGBZ:,"
                        + "KDSTKREIS=:KDSTKREIS:,"
                        + "KDSTORT=:KDSTORT:,"
                        + "KDLSART=:KDLSART:,"
                        + "KDREGMWST=:KDREGMWST:,"
                        + "KDMUSTERKZ=:KDMUSTERKZ:,"
                        + "KDUMSVVJH=:KDUMSVVJH:,"
                        + "KDUMSVJH=:KDUMSVJH:,"
                        + "KDUMSLJH=:KDUMSLJH:,"
                        + "KDPRFZEUG=:KDPRFZEUG:,"
                        + "KDKONZMIT=:KDKONZMIT:,"
                        + "KDRAITING=:KDRAITING:,"
                        + "KDRECHWERT1=:KDRECHWERT1:,"
                        + "KDRECHWERT2=:KDRECHWERT2:,"
                        + "KDRECHWERT3=:KDRECHWERT3:,"
                        + "KDRECHWERT4=:KDRECHWERT4:,"
                        + "KDRECHWERT5=:KDRECHWERT5:,"
                        + "KDKREDKDNR=:KDKREDKDNR:,"
                        + "KDKOND=:KDKOND:,"
                        + "KDKDARTBEZ=:KDKDARTBEZ:,"
                        + "KDKFIBUDAT=:KDKFIBUDAT:,"
                        + "KDKFIBUZEIT=:KDKFIBUZEIT:,"
                        + "KDILN=:KDILN:,"
                        + "KDDEBNRLAE=:KDDEBNRLAE:,"
                        + "KDFACLIMIT=:KDFACLIMIT:,"
                        + "KDSHIPINVD=:KDSHIPINVD:,"
                        + "KDAUFBUTO=:KDAUFBUTO:,"
                        + "KDMAXBST=:KDMAXBST:,"
                        + "KDGRUPPE=:KDGRUPPE:,"
                        + "KDEORI=:KDEORI:,"
                        + "KDEORINL=:KDEORINL:,"
                        + "KDNTSCV=:KDNTSCV:,"
                        + "KDNTSCE=:KDNTSCE:,"
                        + "KDFILLER=:KDFILLER:,"
                        + "KDAENZL=:KDAENZL:,"
                        + "KDAENB=:KDAENB:,"
                        + "KDAEND=:KDAEND: "
                        + " WHERE  "
                        + "  KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR:";
                    #endregion
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    Connect2Proxy(or1);
                    break;
                case 2:
                    or1.CommandText = "UPDATE KDSTAMM SET KDMANDANT=:KDMANDANT:,KDKUNDNR=:KDKUNDNR:,KDKUNDNA=:KDKUNDNA:,KDLAND=:KDLAND:,KDPLZ=:KDPLZ:,KDORT=:KDORT:,KDBZ=:KDBZ:,KDBZBEZ=:KDBZBEZ:,KDSTAKZ=:KDSTAKZ:,KDSTADAT=:KDSTADAT:,KDABCKL=:KDABCKL:,KDANREDE=:KDANREDE:,KDNAME1=:KDNAME1:,KDKNAME=:KDKNAME:,KDNAME2=:KDNAME2:,KDSTRASSE1=:KDSTRASSE1:,KDSTRASSE2=:KDSTRASSE2:,KDPLZPOSTF=:KDPLZPOSTF:,KDPOSTFACH=:KDPOSTFACH:,KDTEL=:KDTEL:,KDTELEX=:KDTELEX:,KDFAX=:KDFAX:,KDBTX=:KDBTX:,KDDATEX=:KDDATEX:,KDHOMEPAGE=:KDHOMEPAGE:,KDMAILADR=:KDMAILADR:,KDTTEX=:KDTTEX:,KDCOUNTY=:KDCOUNTY:,KDCITY=:KDCITY:,KDZENTR=:KDZENTR:,KDZENTRR=:KDZENTRR:,KDSPRKZ=:KDSPRKZ:,KDBBN=:KDBBN:,KDSONDSTA=:KDSONDSTA:,KDKDNRALT=:KDKDNRALT:,KDLO=:KDLO:,KDLB=:KDLB:,KDLP=:KDLP:,KDLIEFNR=:KDLIEFNR:,KDINVDAT=:KDINVDAT:,KDDEBNR=:KDDEBNR:,KDKREDNR=:KDKREDNR:,KDUEBKZ=:KDUEBKZ:,KDAUSK=:KDAUSK:,KDAUSKKZ=:KDAUSKKZ:,KDMAHNST=:KDMAHNST:,KDMAHNH=:KDMAHNH:,KDGRPCUNO=:KDGRPCUNO:,KDCLEARCUNO=:KDCLEARCUNO:,KDBIC1=:KDBIC1:,KDIBAN1=:KDIBAN1:,KDBIC2=:KDBIC2:,KDIBAN2=:KDIBAN2:,KDKREDLIM1=:KDKREDLIM1:,KDKREDVON1=:KDKREDVON1:,KDKREDBIS1=:KDKREDBIS1:,KDKREDNLDAT1=:KDKREDNLDAT1:,KDVERS1=:KDVERS1:,KDVERS21=:KDVERS21:,KDKREDSB1=:KDKREDSB1:,KDVERSTAGE1=:KDVERSTAGE1:,KDVERSNR1=:KDVERSNR1:,KDKREDLIM2=:KDKREDLIM2:,KDKREDVON2=:KDKREDVON2:,KDKREDBIS2=:KDKREDBIS2:,KDKREDNLDAT2=:KDKREDNLDAT2:,KDVERS2=:KDVERS2:,KDVERS22=:KDVERS22:,KDKREDSB2=:KDKREDSB2:,KDVERSTAGE2=:KDVERSTAGE2:,KDVERSNR2=:KDVERSNR2:,KDKREDLIM3=:KDKREDLIM3:,KDKREDVON3=:KDKREDVON3:,KDKREDBIS3=:KDKREDBIS3:,KDKREDNLDAT3=:KDKREDNLDAT3:,KDVERS3=:KDVERS3:,KDVERS23=:KDVERS23:,KDKREDSB3=:KDKREDSB3:,KDVERSTAGE3=:KDVERSTAGE3:,KDVERSNR3=:KDVERSNR3:,KDKREDLIM4=:KDKREDLIM4:,KDKREDVON4=:KDKREDVON4:,KDKREDBIS4=:KDKREDBIS4:,KDKREDNLDAT4=:KDKREDNLDAT4:,KDVERS4=:KDVERS4:,KDVERS24=:KDVERS24:,KDKREDSB4=:KDKREDSB4:,KDVERSTAGE4=:KDVERSTAGE4:,KDVERSNR4=:KDVERSNR4:,KDKREDLIM5=:KDKREDLIM5:,KDKREDVON5=:KDKREDVON5:,KDKREDBIS5=:KDKREDBIS5:,KDKREDNLDAT5=:KDKREDNLDAT5:,KDVERS5=:KDVERS5:,KDVERS25=:KDVERS25:,KDKREDSB5=:KDKREDSB5:,KDVERSTAGE5=:KDVERSTAGE5:,KDVERSNR5=:KDVERSNR5:,KDKREDEHA=:KDKREDEHA:,KDKREDEHAR=:K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MSLJHV:,KDUMSVVJHS=:KDUMSVVJHS:,KDUMSVJHS=:KDUMSVJHS:,KDUMSLJHS=:KDUMSLJHS:,KDQTYUT=:KDQTYUT:,KDQTYVVJH=:KDQTYVVJH:,KDQTYVJH=:KDQTYVJH:,KDQTYLJH=:KDQTYLJH:,KDQTYVVJHV=:KDQTYVVJHV:,KDQTYVJHV=:KDQTYVJHV:,KDQTYLJHV=:KDQTYLJHV:,KDQTYVVJHS=:KDQTYVVJHS:,KDQTYVJHS=:KDQTYVJHS:,KDQTYLJHS=:KDQTYLJHS:,KDPRFZEUG=:KDPRFZEUG:,KDKONZMIT=:KDKONZMIT:,KDRAITING=:KDRAITING:,KDRECHWERT1=:KDRECHWERT1:,KDRECHWERT2=:KDRECHWERT2:,KDRECHWERT3=:KDRECHWERT3:,KDRECHWERT4=:KDRECHWERT4:,KDRECHWERT5=:KDRECHWERT5:,KDKREDKDNR=:KDKREDKDNR:,KDKOND=:KDKOND:,KDKDARTBEZ=:KDKDARTBEZ:,KDKFIBUDAT=:KDKFIBUDAT:,KDKFIBUZEIT=:KDKFIBUZEIT:,KDILN=:KDILN:,KDDEBNRLAE=:KDDEBNRLAE:,KDFACLIMIT=:KDFACLIMIT:,KDSHIPINVD=:KDSHIPINVD:,KDAUFBUTO=:KDAUFBUTO:,KDMAXBST=:KDMAXBST:,KDGRUPPE=:KDGRUPPE:,KDEORI=:KDEORI:,KDEORINL=:KDEORINL:,KDNTSCV=:KDNTSCV:,KDNTSCE=:KDNTSCE:,KDKEYAC=:KDKEYAC:,KDKTOGRP=:KDKTOGRP:,KDZAHLUNG=:KDZAHLUNG:,KDPRAEMIE=:KDPRAEMIE:,KDFILLER=:KDFILLER:,KDAENZL=:KDAENZL:,KDAENB=:KDAENB:,KDAEND=:KDAEND:,KDNEUB=:KDNEUB:,KDNEUD=:KDNEUD:"
                    + " WHERE    KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    Connect2Proxy(or1);
                    break;
                case 3://已付款K
                    or1.CommandText = "UPDATE KDSTAMM  SET (KDVERSUMLTO)=(SELECT SUM(VRPGESWERT*0.001*0.001) FROM VRPOS JOIN VRKOPF ON VRPMANDANT=VRKMANDANT AND VRPRENR=VRKRENR WHERE VRPBONKZ='J' AND VRKKUNDNR=KDKUNDNR  AND VRPARTKUNDNR= VRKKUNDNR)"
                        + " WHERE KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR: AND EXISTS (SELECT 1 FROM VRPOS JOIN VRKOPF ON VRPMANDANT=VRKMANDANT  AND VRPRENR=VRKRENR   WHERE VRPBONKZ='J' AND VRKKUNDNR=KDKUNDNR  AND VRPARTKUNDNR= VRKKUNDNR)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    Connect2Proxy(or1);
                    break;
                case 4://未支付
                    or1.CommandText = "UPDATE KDSTAMM  SET (KDVERSUML)=(SELECT SUM(VRPGESWERT*0.001) FROM VRPOS JOIN VRKOPF ON VRPMANDANT=VRKMANDANT AND VRPRENR=VRKRENR WHERE   VRPBONKZ='N'  AND VRKKUNDNR=KDKUNDNR  AND VRPARTKUNDNR= VRKKUNDNR)"
                        + " WHERE KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR: AND EXISTS (SELECT 1 FROM VRPOS JOIN VRKOPF ON VRPMANDANT=VRKMANDANT  AND VRPRENR=VRKRENR   WHERE  VRPBONKZ='N'  AND VRKKUNDNR=KDKUNDNR AND VRPARTKUNDNR= VRKKUNDNR)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    Connect2Proxy(or1);
                    break;
                case 5:
                    UKD05(dwData);
                    break;
            }

        }
        public void UKD05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE KDSTAMM SET KDMANDANT=:KDMANDANT:,KDKUNDNR=:KDKUNDNR:,KDKUNDNA=:KDKUNDNA:,KDL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1=:KDVERSTAGE1:,KDVERSNR1=:KDVERSNR1:,KDKREDLIM2=:KDKREDLIM2:,KDKREDVON2=:KDKREDVON2:,KDKREDBIS2=:KDKREDBIS2:,KDKREDNLDAT2=:KDKREDNLDAT2:,KDVERS2=:KDVERS2:,KDVERS22=:KDVERS22:,KDKREDSB2=:KDKREDSB2:,KDVERSTAGE2=:KDVERSTAGE2:,KDVERSNR2=:KDVERSNR2:,KDKREDLIM3=:KDKREDLIM3:,KDKREDVON3=:KDKREDVON3:,KDKREDBIS3=:KDKREDBIS3:,KDKREDNLDAT3=:KDKREDNLDAT3:,KDVERS3=:KDVERS3:,KDVERS23=:KDVERS23:,KDKREDSB3=:KDKREDSB3:,KDVERSTAGE3=:KDVERSTAGE3:,KDVERSNR3=:KDVERSNR3:,KDKREDLIM4=:KDKREDLIM4:,KDKREDVON4=:KDKREDVON4:,KDKREDBIS4=:KDKREDBIS4:,KDKREDNLDAT4=:KDKREDNLDAT4:,KDVERS4=:KDVERS4:,KDVERS24=:KDVERS24:,KDKREDSB4=:KDKREDSB4:,KDVERSTAGE4=:KDVERSTAGE4:,KDVERSNR4=:KDVERSNR4:,KDKREDLIM5=:KDKREDLIM5:,KDKREDVON5=:KDKREDVON5:,KDKREDBIS5=:KDKREDBIS5:,KDKREDNLDAT5=:KDKREDNLDAT5:,KDVERS5=:KDVERS5:,KDVERS25=:KDVERS25:,KDKREDSB5=:KDKREDSB5:,KDVERSTAGE5=:KDVERSTAGE5:,KDVERSNR5=:KDVERSNR5:,KDKREDEHA=:KDKREDEHA:,KDKREDEHAR=:KDKREDEHAR:,KDKREDNOLI=:KDKREDNOLI:,KDKREDNOLIV=:KDKREDNOLIV:,KDKREDNOLIB=:KDKREDNOLIB:,KDAUFBESTTO=:KDAUFBESTTO:,KDVERSUMLTO=:KDVERSUMLTO:,KDOPSALDOTO=:KDOPSALDOTO:,KDZUSKRED=:KDZUSKRED:,KDZKREVON=:KDZKREVON:,KDZKREBIS=:KDZKREBIS:,KDZ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KDQTYLJHV:,KDQTYVVJHS=:KDQTYVVJHS:,KDQTYVJHS=:KDQTYVJHS:,KDQTYLJHS=:KDQTYLJHS:,KDPRFZEUG=:KDPRFZEUG:,KDKONZMIT=:KDKONZMIT:,KDRAITING=:KDRAITING:,KDRECHWERT1=:KDRECHWERT1:,KDRECHWERT2=:KDRECHWERT2:,KDRECHWERT3=:KDRECHWERT3:,KDRECHWERT4=:KDRECHWERT4:,KDRECHWERT5=:KDRECHWERT5:,KDKREDKDNR=:KDKREDKDNR:,KDKOND=:KDKOND:,KDKDARTBEZ=:KDKDARTBEZ:,KDKFIBUDAT=:KDKFIBUDAT:,KDKFIBUZEIT=:KDKFIBUZEIT:,KDILN=:KDILN:,KDDEBNRLAE=:KDDEBNRLAE:,KDFACLIMIT=:KDFACLIMIT:,KDSHIPINVD=:KDSHIPINVD:,KDAUFBUTO=:KDAUFBUTO:,KDMAXBST=:KDMAXBST:,KDGRUPPE=:KDGRUPPE:,KDEORI=:KDEORI:,KDEORINL=:KDEORINL:,KDNTSCV=:KDNTSCV:,KDNTSCE=:KDNTSCE:,KDKEYAC=:KDKEYAC:,KDKTOGRP=:KDKTOGRP:,KDZAHLUNG=:KDZAHLUNG:,KDPRAEMIE=:KDPRAEMIE:,KDFILLER=:KDFILLER:,KDAENZL=:KDAENZL:,KDAENB=:KDAENB:,KDAEND=:KDAEND:,KDNEUB=:KDNEUB:,KDNEUD=:KDNEUD:"
                   + " WHERE    KDMANDANT=:KDMANDANT: AND KDKUNDNR=:KDKUNDNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
    }

}
